
<div style="POSITION: relative" id="content">
  <h3>easyUI 根据一些条件改变DataGrid 行背景颜色</h3>
  <div id="article_content" class="article_content">
    <p>这个教程将向你展示如何改变datagrid组件行样式根据一些条件,谁的listprice 值大于50我们将设置行为不同的颜色.</p>
    <p><img src="documentation/images/1344653655_6055.png" alt=""></p>

    <p>datagrid的函数设计允许你自定义行样式,以下代码展示如何改变</p>
    <p>
    <pre name="code" class="html">&lt;table id=&quot;tt&quot; title=&quot;DataGrid&quot; style=&quot;width:600px;height:250px&quot;  
        url=&quot;data/datagrid_data.json&quot;  
        singleSelect=&quot;true&quot; fitColumns=&quot;true&quot;&gt;  
    &lt;thead&gt;  
        &lt;tr&gt;  
            &lt;th field=&quot;itemid&quot; width=&quot;80&quot;&gt;Item ID&lt;/th&gt;  
            &lt;th field=&quot;productid&quot; width=&quot;80&quot;&gt;Product ID&lt;/th&gt;  
            &lt;th field=&quot;listprice&quot; width=&quot;80&quot; align=&quot;right&quot;&gt;List Price&lt;/th&gt;  
            &lt;th field=&quot;unitcost&quot; width=&quot;80&quot; align=&quot;right&quot;&gt;Unit Cost&lt;/th&gt;  
            &lt;th field=&quot;attr1&quot; width=&quot;150&quot;&gt;Attribute&lt;/th&gt;  
            &lt;th field=&quot;status&quot; width=&quot;60&quot; align=&quot;center&quot;&gt;Stauts&lt;/th&gt;  
        &lt;/tr&gt;  
    &lt;/thead&gt;  
&lt;/table&gt;  </pre>
    <pre name="code" class="javascript">$('#tt').datagrid({  
    rowStyler:function(index,row){  
        if (row.listprice&gt;50){  
            return 'background-color:pink;color:blue;font-weight:bold;';  
        }  
    }  
});  </pre>
    正如你所看到的,我们根据一些条件设置<span style="font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; font-size:14px; text-align:left">background-color(背景色)为pink(分红色)和文本颜色为blue(蓝色);</span>
    </p>

    <h4 style="font-size:16px; color:rgb(204,0,0); margin:10px 0px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left"> 下载EasyUI 示例代码:</h4>
    <div style="font-size:14px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left; padding-left:50px"> <a href="http://www.jeasyui.com/tutorial/datagrid/downloads/easyui-datagrid18-demo.zip" target="_blank" class="download-link" style="color:rgb(0,0,255)">easyui-datagrid-demo.zip</a></div>
    <br>
  </div>
</div>
<SCRIPT type=text/javascript>
	dp.SyntaxHighlighter.ClipboardSwf = 'documentation/js/clipboard.swf'/*tpa=http://jeasyui.com/SyntaxHighlighter/Scripts/clipboard.swf*/;
	dp.SyntaxHighlighter.HighlightAll('code');
</SCRIPT>